<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>李宁体育</title>
     <link rel="shortcut icon" href="favicon.ico">
    <link href="<%=path%>/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path%>/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="<%=path%>/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="<%=path%>/css/plugins/chosen/chosen.css" rel="stylesheet">

    <link href="<%=path%>/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
          rel="stylesheet">
    <link href="<%=path%>/css/animate.min.css" rel="stylesheet">
    <link href="<%=path%>/css/style.min862f.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改幻灯片</h5>                
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" action="saveBannerInfo.do" method="post" id="saveBannerInfoForm" enctype="multipart/form-data">
                                    <input type="hidden" name="id" id="id" value="${bannerInfo.id}"/>
                                    <div class="form-group">
										<label class="col-sm-2 control-label">类型</label><font color="red">*</font>
										<div class="col-sm-3">
										   <select class="form-control m-b" name="type" id="type">
												<option value="1" <c:if test="${bannerInfo.type == '1'}">selected</c:if>>积分商城</option>
												<option value="2" <c:if test="${bannerInfo.type == '2'}">selected</c:if>>当月精选</option>
												<option value="3" <c:if test="${bannerInfo.type == '3'}">selected</c:if>>每月团购</option>
											</select>
										</div>
									</div>                                    
                                    <div class="form-group">
									<label class="col-sm-2 control-label">排序</label>
									<div class="col-sm-3">
											<input type="text" class="form-control" name="sort" id="sort" value="${bannerInfo.sort}" placeholder="排序"></input>
									</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">幻灯片标题</label><font color="red">*</font>
										<div class="col-sm-3">
											<input type="text" class="form-control" name="name" id="name" value="${bannerInfo.name}" placeholder="标题"></input>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">幻灯片图片</label>
										<div class="col-sm-3">						
										    <input id="picture" name="picture"   type="file"  maxlength="128" title="图片" placeholder="图片" onchange="validateImg();"/>
										    <span id="imgHint" style="color:red">图片比例5:2,建议尺寸750x300px,大小不能超过1M</span>
										    <!-- </br>
										    <span id="imgsize" style="color:red"></span> -->
										</div>
									</div>	
									<div class="form-group">
										<label class="col-sm-2 control-label">幻灯片链接</label>
										<div class="col-sm-3">
											<input type="text" class="form-control" name="linkUrl" id="linkUrl" value="${bannerInfo.linkUrl}"  placeholder="链接"></input>
										</div>
									</div>	
									<div class="form-group">
                                        <label class="col-sm-2 control-label">是否显示：</label>
                                        <div class="col-sm-3">
                                                                                                          是&nbsp;&nbsp;<input  name="isShow"  type="radio" value="1"  <c:if test="${bannerInfo.isShow eq '1'}">checked</c:if>/>&nbsp;&nbsp;&nbsp;&nbsp;
                                                                                                          否&nbsp;&nbsp;<input  name="isShow"  type="radio" value="0"  <c:if test="${bannerInfo.isShow eq '0'}">checked</c:if>/>
                                        </div>
                                    </div>									
									<div class="form-group">
                                         <div class="col-sm-4 col-sm-offset-3">
                                          <button class="btn btn-primary" type="submit" >保 存</button>
                                          &nbsp;<button class="btn btn-info" type="button" onclick="goback()">返回</button>
                                         </div>
                                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="<%=path%>/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=path%>/js/bootstrapValidator.min.js"></script>
<!--下拉框-->
<script src="<%=path%>/js/plugins/chosen/chosen.jquery.js"></script>

<script>
	function validateImg() {
		var maxsize = 1*1024*1024;  //1M  
		var img = $("#picture").val().toLowerCase().split('.');
		var obj_file = document.getElementById("picture"); 
		if (img == '') {
		} else {
			if (img[img.length - 1] == 'gif' || img[img.length - 1] == 'jpg'|| img[img.length - 1] == 'jpeg'|| img[img.length - 1] == 'png') {
				var filesize = 0;  
	            filesize = obj_file.files[0].size
	            if(filesize>maxsize){
	            	/* errMsg = "上传的图片文件不能超过1M！";
	            	$("#imgsize").html(errMsg) */
	            	$("#picture").val("");
	                return false;
	            }
			} else {
				$("#picture").val("");
				return false;
			}
		}
	}
	function goback() {
		window.location.href = "<%=path%>/bannerInfo/queryBannerInfoList";
    }
    //表单验证
    var config = {
            ".chosen-select": {},
            ".chosen-select-deselect": {allow_single_deselect: !0},
            ".chosen-select-no-single": {disable_search_threshold: 10},
            ".chosen-select-no-results": {no_results_text: "Oops, nothing found!"},
            ".chosen-select-width": {width: "95%"}
    };
    
    for (var selector in config)$(selector).chosen(config[selector]);
    $(document).ready(function () {
        $('#saveBannerInfoForm').bootstrapValidator({
            message: 'This value is not valid',
            fields: {
            	name: {
                    message: '幻灯片标题不能为空！',
                    validators: {
                        notEmpty: {
                            message: '幻灯片标题不能为空！'
                        }
                    }
                },
            },
            submitHandler: function(validator, form, submitButton) {
            }
        });
    });
</script>
</body>
</html>
